//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics.Contracts;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    public class TableStyleInfo: IOfficeXmlSerializable
    {
        public TableStyleInfo()
        {
            
        }

        public TableStyleInfo(Table table)
        {
            ColumnStripesVisible = table.ColumnStripesVisible;
            FirstColumnVisible = table.FirstColumnVisible;
            LastColumnVisible = table.LastColumnVisible;
            RowStripesVisible = table.RowStripesVisible;
            Name = table.Style.Name;
        }
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read("tableStyleInfo"))
            {
                Name = c.GetOptionalString("name");
                FirstColumnVisible = c.GetOptionalBoolean("showFirstColumn", false);
                LastColumnVisible = c.GetOptionalBoolean("showLastColumn", false);
                RowStripesVisible = c.GetOptionalBoolean("showRowStripes", false);
                ColumnStripesVisible = c.GetOptionalBoolean("showColumnStripes", false);

            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("tableStyleInfo"))
            {
                c.SetOptionalString("name", Name);
                c.SetBoolean("showFirstColumn", FirstColumnVisible);
                c.SetBoolean("showLastColumn", LastColumnVisible);
                c.SetBoolean("showRowStripes", RowStripesVisible);
                c.SetBoolean("showColumnStripes", ColumnStripesVisible);

            }
        }

        #endregion

        private string _name;
        public string Name
        {
            get
            {

                return _name;
            }
            set
            {
                _name = value;
            }
        }
        [Obsolete("Use FirstColumnVisible instead")]
        public bool ShowFirstColumn { get; set; }

        [Obsolete("Use LastColumnVisible instead")]
        public bool ShowLastColumn { get; set; }

        public bool FirstColumnVisible { get { return ShowFirstColumn; } set { ShowFirstColumn = value; } }

        public bool LastColumnVisible { get { return ShowLastColumn; }set { ShowLastColumn = value; }}

        private bool showRowStripes = true;

        [Obsolete("Use RowStripesVisible instead")]
        public bool ShowRowStripes
        {
            get { return showRowStripes; }
            set { showRowStripes = value; }
        }
        public bool RowStripesVisible
        {
            get { return showRowStripes; }
            set { showRowStripes = value; }
        }
        [Obsolete("Use ColumnStripesVisible instead")]
        public bool ShowColumnStripes { get; set; }
        public bool ColumnStripesVisible { get { return ShowColumnStripes; } set { ShowColumnStripes = value; } }
        public void CopyTo(Table table)
        {
            table.ColumnStripesVisible = ColumnStripesVisible;
            table.LastColumnVisible = LastColumnVisible;
            table.RowStripesVisible = RowStripesVisible;
            
        }
    }
}
